package ace.module.account.sdk.core.feign.impl;

import ace.cmp.core.model.R;
import ace.cmp.openfeign.security.oauth2.core.config.FeignInternalServerOauth2SecurityConfig;
import ace.module.account.api.model.auth.dto.AuthenticationResult;
import ace.module.account.api.model.auth.input.AuthenticationInputMap;
import ace.module.account.api.model.auth.input.GenericAuthenticationInput;
import ace.module.account.sdk.core.constant.SdkConstant;
import ace.module.common.api.annotation.ApiRemoteProxyPriority;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 账户认证 rpc contract.
 *
 * @author Caspar
 */
@FeignClient(
    name = "${spring.cloud.openfeign.client.iamAuthenticationFeign.name:" + SdkConstant.FEIGN_SERVICE_NAME + "}",
    contextId = "iamAuthenticationFeign",
    path = IamAuthenticationFeign.PATH,
    configuration = FeignInternalServerOauth2SecurityConfig.class,
    primary = false
)
@ApiRemoteProxyPriority
public interface IamAuthenticationFeign {

  String PATH =
      "${spring.cloud.openfeign.client.iamAuthenticationFeign.path:/account/iam-authentication/rpc}";

  /**
   * 账户认证，标签过滤
   *
   * @param input {@link AuthenticationInputMap} {@link GenericAuthenticationInput}
   * @return
   */
  @PostMapping("/authentication")
  R<AuthenticationResult> authentication(@Valid @NotEmpty @RequestBody String input);
}
